package uz.gov.pages;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.testng.Assert;

/**
 * Created by IIGalytska on 04.04.14.
 */
public class CartWindow {
    private WebDriver driver;

    public CartWindow(WebDriver driver){

        this.driver = driver;
    }


    public CheckoutPage pressCheckoutButton(){

        driver.findElement(By.className("cart-popup")).findElement(By.cssSelector("#popup-checkout > span > span > span")).click();;
        return new CheckoutPage(driver);
    }


    public String selectInvalidNumberOfGoods(String numberOfGoods){


        WebElement inputElement4 = driver.findElement(By.className("cart-popup")).findElement(By.name("quantity"));
        inputElement4.clear();
        inputElement4.sendKeys(numberOfGoods);
        Assert.assertEquals(numberOfGoods, inputElement4.getAttribute("value"));

        driver.findElement(By.className("cart-popup")).findElement(By.cssSelector("#popup-checkout > span > span > span")).click();
        WebElement inputElement5 = driver.findElement(By.id("quantity"));

        return inputElement5.getAttribute("style");

}

}
